@layout("/common/_container.html"){

<div style="display: none">
    <input type="hidden" id="customerId" value="${customerId}">
    <input type="hidden" id="idValue" value="${id2}">
    <input type="hidden" id="reservationsId" value="${reservationsId}">
    <input type="hidden" id="operationTime" value="${operationTime}">
    <input type="hidden" id="doctor" value="${consultantInfo.doctor}">
    <input type="hidden" id="nurse" value="${consultantInfo.nurse}">
</div>
<div>分配医生</div>
<div class="content"></div>

<div>分配医助/护士</div>
<div class="content"></div>

<input type="button" value="提交" id="submit"/>

<style>
    #chils {
        display: inline-block;
        width: 30%;
    }
</style>

<link rel="stylesheet" href="${ctxPath}/static/css/jqui/jquery-ui.min.css">
<script src="${ctxPath}/static/js/jquery-ui.min.js"></script>
<script src="${ctxPath}/static/modular/tcCenter/consultant/consultant_info.js"></script>
<script>
    $(function () {
        //把数据渲染到archiving_content容器里面
        var dom = document.getElementsByClassName('content')[0];
        var dom1 = document.getElementsByClassName('content')[1];
        $.ajax({
            url: Feng.ctxPath + "/consultant/getDoctor",
            type: "get",
            success: function (data) {
                var doctors = $("#doctor").val();
                console.log(doctors);
                var fragment = document.createDocumentFragment();
                var ul = document.createElement("ul");
                var listr = '';
                for (var i = 0; i < data.length; i++) {
                    listr += "<li id='chils'><label><input class='ipt' type='radio' value='" + data[i].doctor + "' name='me' />" + data[i].doctor + "</label></li>";
                }
                ul.innerHTML = listr;
                fragment.appendChild(ul);
                dom.appendChild(fragment);
                $('input[value='+doctors+']').attr('checked',true);
            },
            error: function (data) {
                alert('内部故障!');
            }
        });
        $.ajax({
            url: Feng.ctxPath + "/consultant/getNurse",
            type: "get",
            success: function (data) {
                var nurses = $("#nurse").val();
                console.log(nurses);
                var fragment = document.createDocumentFragment();
                var ul = document.createElement("ul");
                var listr = '';
                for (var i = 0; i < data.length; i++) {
                    listr += "<li id='chils'><label><input class='ipt1' type='radio' value='" + data[i].nurse + "' name='to' />" + data[i].nurse + "</label></li>";
                }
                ul.innerHTML = listr;
                fragment.appendChild(ul);
                dom1.appendChild(fragment);
                $('input[value='+nurses+']').attr('checked',true);
            },
            error: function (data) {
                alert('内部故障!');
            }
        });
    });



    var ipt = document.getElementsByClassName('ipt');
    var ipt1 = document.getElementsByClassName('ipt1');
    var submit = document.getElementById("submit");
    var a = $("#idValue").val();
    var doctor;
    var nurse;

    submit.onclick = function () {
        for (var i = 0; i < ipt.length; i++) {
            if (ipt[i].checked) {
                doctor = ipt[i].value;
                window.parent.document.getElementById("y_" + a).innerHTML = "医生：" + doctor;
            }
        }
        for (var j = 0; j < ipt1.length; j++) {
            if (ipt1[j].checked) {
                nurse = ipt1[j].value;
                window.parent.document.getElementById("h_" + a).innerHTML = "护士：" + nurse;
            }
        }
        $.ajax({
            url: "${ctxPath}/consultant/updateDoctorNurse",
            type: "post",
            data: {
                doctor: doctor,
                nurse: nurse,
                customerId: $("#customerId").val(),
                id2: $("#idValue").val(),
                reservationsId: $("#reservationsId").val(),
                operationTime: $("#operationTime").val()
            },
            success: function (data) {

            }
        })

        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    }

</script>
@}
